import request from '@/utils/request'

export function getDepartmentList() {
  return request({
    url: '/company/department'
  })
    .then(res => res.data.data.depts)
    .catch(() => [])
}
// 部门新增
export function postDepartmentList(params) {
  return request({
    url: '/company/department',
    method: 'post',
    data: params
  })
    .then(res => res.data.message)
    .catch(() => Promise.reject(err.response.data.message))
}

// 部门删除
export function deleteDepartment(id) {
  return request({
    url: '/company/department/' + id,
    method: 'delete',
  })
    .then(res => res.data.message)
    .catch(() => Promise.reject(err.response.data.message))
}
// 部门修改
export function putDepartment(params) {
  return request({
    url: '/company/department/' + params.id,
    method: 'put',
    data: {
      ...params
    }
  })
    .then(res => res.data.message)
    .catch(() => Promise.reject(err.response.data.message))
}
